package com.fjec.devops.service.impl;

import com.fjec.common.enums.EnumSysCode;
import com.fjec.common.protocol.JsonResult;
import com.fjec.common.shiro.AccountInfo;
import com.fjec.common.util.DateUtil;
import com.fjec.devops.entity.BizFeedback;
import com.fjec.devops.mapper.BizFeedbackMapper;
import com.fjec.devops.service.IBizFeedbackService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 * 004.意见反馈表 服务实现类
 * </p>
 *
 * @author admin
 * @since 2020-09-18
 */
@Service
public class BizFeedbackServiceImpl extends ServiceImpl<BizFeedbackMapper, BizFeedback> implements IBizFeedbackService {

    @Resource
    private BizFeedbackMapper mapper;

    @Override
    public JsonResult sendFeedback(String feedback) {
        int busiType = AccountInfo.getBusiType();
        BizFeedback entity = new BizFeedback();

        entity.setBusiType(busiType);
        entity.setUserId(AccountInfo.getUserId());
        entity.setReaded(0);
        entity.setFeedback(feedback);
        entity.setCreateTime(DateUtil.nowLdt());
        switch (busiType) {
            case 1:
                entity.setShopName(AccountInfo.getWxNickName());
                break;
            case 2:
            case 3:
            case 4:
            case 5:
            case 6:
                entity.setBusiId(AccountInfo.getBusiId());
                entity.setShopName(AccountInfo.getShopName());
                break;
        }
        mapper.insert(entity);
        return JsonResult.success()
                .code(EnumSysCode.MSG_6002.getCode())
                .message(EnumSysCode.MSG_6002.getMsg())
                .build();
    }
}
